#include <stdio.h>

// 方法1: 先定义结构体类型，再定义结构体变量
struct student
{
    int num;
    char name[16];
    float score;
};

// 方法1.1: 定义一个tom的结构体变量，并赋初值
struct student tom = {
	.num   = 1,
	.name  = "tom",
	.score = 50
};

// 方法2: 简化结构体类型的定义，可以使用typedef为结构体类型取一个别名
typedef struct __student
{
    int num;
    char name[16];
    float score;
} student_t;

// 方法2.1: 使用别名定义结构体变量，不需要每次都使用struct关键字。
student_t jerry = {
	.num   = 2,
	.name  = "jerry",
	.score = 60
};

int main(int argc, char const *argv[])
{
    // 方法1.2: 定义一个lucy的结构体变量，并赋初值
    struct student lucy = {3, "lucy", 99.9};

    // 方法2.2: 定义一个lucy的结构体变量，并赋初值
    student_t lily = {4, "lily", 80};

    printf("num = %d \n", lucy.num);
    printf("name = %s \n", lucy.name);
    printf("score = %.2f \n", lucy.score);

    printf("num = %d \n", tom.num);
    printf("name = %s \n", tom.name);
    printf("score = %.2f \n", tom.score);

    printf("num = %d \n", jerry.num);
    printf("name = %s \n", jerry.name);
    printf("score = %.2f \n", jerry.score);

    printf("num = %d \n", lily.num);
    printf("name = %s \n", lily.name);
    printf("score = %.2f \n", lily.score);

    return 0;
}